//define(function(require,exports){

  angular.module('mobileApp')
      .controller('LoginCtrl',["$scope","$location","$http","$window","$routeParams", function ($scope,$location,$http,$window,$routeParams) {
          //shopId和场景
          $scope.shopId = $window.localStorage.shopId ? $window.localStorage.shopId :'0';
          $scope.scene = $window.localStorage.scene ? $window.localStorage.scene :'0';

          //表单元素
          $scope.user = {
              account:"",
              password:""
          };
          //提交
          $scope.loginForm = function(){
              $scope.hasError = "";
              $http({
                  method:"post",
                  url:hpfbase.url+"/user/login-pwd.jhtm",
                  headers: {
                      'Content-Type': "application/x-www-form-urlencoded;charset=utf-8"
                  },
                  data:"account="+$scope.user.account+"&password="+$scope.user.password
              })
                  .success(function(ret){
                      if(ret.statusCode == 1){
                          //没有shopID,没有查看店铺
                          if($scope.shopId==0){
                              $window.location.href="mine.html";
                          }else{
                              //如果有shopId.扫码，预订
                              if($scope.scene=="bookNodish"){
                                  //扫码进来的

                              }else if($scope.scene=="bookIndish"){
                                  //预订不点餐

                              }else if($scope.scene=="bookIndish") {
                                  //预订点餐

                              }else{
                                  //店铺进来
                                  $window.location.href= "shop.html#/category";
                              }
                          }
                      }else{
                          $scope.hasError = "用户名或密码错误！";
                      }
                  });
          };
          //注册
          $scope.js_reg = function(){
              $location.path("/reg");
          }
          //忘记密码
          $scope.js_mobile = function(){
              $location.path("/forget");
          }
      }]);
//});
